﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using InsightAuto.Domain.Core;
using System.Data.Entity;
using System.Data.Objects;

namespace InsightAuto.Web
{
    // 注意: 有关启用 IIS6 或 IIS7 经典模式的说明，
    // 请访问 http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


            //routes.MapRoute(
            //    "Cae", // 路由名称
            //    "t/{action}/{id}", // 带有参数的 URL
            //    new { controller = ControllerNames.Car, action = "Index" } // 参数默认值
            //);

            //routes.MapRoute(
            //    "Series", // 路由名称
            //    "s/{action}/{id}", // 带有参数的 URL
            //    new { controller = ControllerNames.Series, action = "Index", id = 0 } // 参数默认值
            //);

            //routes.MapRoute(
            //    "Brand", // 路由名称
            //    "b/{action}/{id}", // 带有参数的 URL
            //    new { controller = ControllerNames.Brand, action = "Index", id = 0 } // 参数默认值
            //);

            //routes.MapRoute(
            //    "News", // 路由名称
            //    "news/{action}/{id}", // 带有参数的 URL
            //    new { controller = ControllerNames.News, action = "Show" } // 参数默认值
            //);

            //routes.MapRoute(
            //    "Content", // 路由名称
            //    "Content/{action}", // 带有参数的 URL
            //    new { controller = ControllerNames.Content, action = "Upload" } // 参数默认值
            //);

            //routes.MapRoute(
            //    "NewsPanel", // 路由名称
            //    "pan/{count}/{category}-{showTitleBar}/", // 带有参数的 URL
            //    new { controller = ControllerNames.Home, action = "NewsPanel", count = 10, category = string.Empty, showTitleBar = true } // 参数默认值
            //);

            routes.MapRoute(
                "Default", // 路由名称
                "{controller}/{action}/{id}", // 带有参数的 URL
                new { controller = ControllerNames.Home, action = "Index", id = UrlParameter.Optional }, // 参数默认值
                new string[] { "InsightAuto.Web.Controllers" }
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            DbInitializer.InitCore(new CoreContainer());

        }
    }
}